home *** CD-ROM | disk | FTP | other *** search
- //=========================================================
- //
- // main.c
- //
- // Simple Unix-style mailer for use with ka9q/DIS
- //
- //=========================================================
-
- char VERSION[]=
- "MAILER $Revision: 1.10 $ $Date: 1994/02/20 19:13:16 $";
-
- static char rcsid[]=
- "$Id: main.c,v 1.10 1994/02/20 19:13:16 gbj Exp user $";
-
- /*
- $Log: main.c,v $
- * Revision 1.10 1994/02/20 19:13:16 gbj
- * Added mail aliasing.
- *
- * Revision 1.9 1994/02/14 23:35:06 gbj
- * Incorporated Alec Jones's mods to log outgoing mail.
- * New module log.c
- * Changed modules init.c and mail.c
- *
- * Revision 1.8 1994/02/12 01:28:38 gbj
- * Display mailbox index before each command request.
- * When the index is displayed, display cmsg-8 to cmsg-8+16, if cmsg-8
- * is less than zero, display 0 to 16.
- * Enabled blinking cursor.
- *
- * Revision 1.7 1994/02/08 23:32:02 gbj
- * First public release.
- *
- * Revision 1.6 1994/02/08 23:30:28 gbj
- * New function: read next unread message.
- *
- * Revision 1.5 1994/02/08 22:01:42 gbj
- * Still fixing up version keywords...
- *
- * Revision 1.4 1994/02/08 22:00:24 gbj
- * Fixup version keywords
- *
- * Revision 1.3 1994/02/08 21:56:36 gbj
- * Added version variable.
- *
- * Revision 1.2 1994/02/08 03:20:50 gbj
- * Made Id keyword a static char so that Ident can display it.
- *
- * Revision 1.1 1994/02/08 03:15:10 gbj
- * Initial revision
- *
- */
-
- // Set plenty of stack
- unsigned long _STACK=32768L;
-
-
- #include "mailer.h"
-
- void main(void)
- {
- int res;
- int msgno;
- COMMAND cmd;
- char xuser[128], xfile[128];
-
- init(VERSION);
- res=loadix(user);
- if (res == 3)
- {
- fprintf(stderr," loadix returned %d\n", res);
- exit(res);
- }
-
- if (res == 1 || res == 2)
- {
- cmsg=-1;
- maxmsgno=-1;
- }
- else
- cmsg=0;
-
- msgno=cmsg;
- *xuser='\0';
- *xfile='\0';
- cmd=BAD;
-
- Cursconf(1, 0); // Show cursor
- Cursconf(2, 0); // Make it blink
- while (cmd != QUITX && cmd != QUIT)
- {
- if (cmsg-8 < 0)
- showix(0, cmsg);
- else
- showix(cmsg-8, cmsg);
-
- cmd=getcmd(&msgno, xuser, xfile);
-
- switch (cmd)
- {
- case DELETE:
- if (maxmsgno != -1)
- mark(msgno, TRUE);
- break;
-
- case MAIL:
- case MAILFILE:
- mailto(xuser, xfile);
- break;
-
- case SAVE:
- if (maxmsgno != -1)
- saveto(xfile, TRUE);
- break;
-
- case WRITE:
- if (maxmsgno != -1)
- saveto(xfile, FALSE);
- break;
-
- case REPLY:
- if (maxmsgno != -1)
- replyto(msgno);
- break;
-
- case FORWARD:
- if (maxmsgno != -1)
- forwardto(msgno, xuser);
- break;
-
- case UNDELETE:
- if (maxmsgno != -1)
- mark(msgno, FALSE);
- break;
-
- case NEXT:
- if (maxmsgno != -1)
- bump(1);
- break;
-
- case PREV:
- if (maxmsgno != -1)
- bump(-1);
- break;
-
- case READ:
- case PRINT:
- if (maxmsgno != -1)
- {
- cmsg=msgno;
- showmsg(msgno);
- mailix[cmsg].rflag=1;
- }
- break;
-
- case HEADER:
- if (maxmsgno != -1)
- showix(msgno, cmsg);
- break;
-
- case LIST:
- listqueue();
- break;
-
- case NEW:
- newmbox(xfile);
- break;
-
- case QUITX:
- quit(FALSE);
- break;
-
- case QUIT:
- if (maxmsgno != -1)
- quit(TRUE);
- else
- quit(FALSE);
- break;
-
- case HELP:
- help();
- break;
-
- case UNREAD:
- if (msgno != -1)
- {
- int ix;
- for (ix=0; ix <= maxmsgno; ix++)
- {
- if (mailix[ix].rflag != 1)
- {
- showmsg(ix);
- mailix[ix].rflag=1;
- cmsg=ix;
- break;
- }
- }
- }
- break;
-
- default:
- help();
- break;
- }
- }
-
- exit(0);
- }
-
- void help(void)
- {
- printf("\nCOMMANDS AVAILABLE:\n");
- printf("m user send mail to a user\n");
- printf("t user file send mail from a file to a user\n");
- printf("f user [msg] forward message to a user\n");
- printf("r [msg] reply to a message\n");
- printf("ENTER show next unread message\n");
- printf("msg show message\n");
- printf("p [msg] show message\n");
- printf("s [file] save message in a file\n");
- printf("w [file] save message without headers\n");
- printf("d [msg] mark message as deleted\n");
- printf("u [msg] mark message as undeleted\n");
- printf("+ goto next message\n");
- printf("- goto previous message\n");
- printf("h [msg] list headers starting at msg\n");
- printf("n mbox change mailbox\n");
- printf("l list unsent messages\n");
- printf("x exit without updating mailbox\n");
- printf("q exit with updating\n");
- printf("? This help text\n");
- printf("[msg] - message number, default to current message\n");
- printf("[file] - file name, default to mbox.txt\n");
- printf("mbox - mailbox name\n");
- printf("Press a key...");
- getch();
- putchar('\n');
- return;
- }
-
-